package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteFarmerService;
import com.ruoyi.system.api.domain.vo.CropsVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 农户服务降级处理
 *
 * @author 王泽超的电脑
 */
@Component
public class RemoteFarmerFallbackFactory implements FallbackFactory<RemoteFarmerService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteFarmerFallbackFactory.class);


    @Override
    public RemoteFarmerService create(Throwable throwable) {
        log.error("农户服务调用失败:{}", throwable.getMessage());
        return new RemoteFarmerService() {
            @Override
            public R<Integer> updateMachingStatus(CropsVo cropsVo, String source) {

                return R.fail("调用修改农产品加工状态方法失败:" + throwable.getMessage());
            }

            @Override
            public R<Integer> updateProductWriteStatus(String cropsId, String source) {
                return R.fail("调用修改农产品填写状态方法失败:" + throwable.getMessage());
            }

            @Override
            public R<Integer> productOutFactory(String cropsId, String source) {
                return R.fail("调用农产品出库方法失败:" + throwable.getMessage());
            }
        };
    }
}
